//
//  MoreView.m
//  SYiDaiy
//
//  Created by dllo on 16/9/14.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "MoreView.h"
#import "MoreViewCollectionViewCell.h"

@interface MoreView ()<UICollectionViewDataSource,UICollectionViewDelegate>

@end

@implementation MoreView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        _flow = [UICollectionViewFlowLayout new];
        _flow.itemSize = CGSizeMake(355 / 2, 60);
        _flow.minimumInteritemSpacing = 0;
        _flow.minimumLineSpacing = 0;
        _flow.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
        _moreLabel = [UILabel new];
        _moreLabel.backgroundColor = [UIColor redColor];
        _moreLabel.text = @"如果你喜欢每日腕表杂志，不防:";
        [self addSubview:_moreLabel];
        _appstoreButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _appstoreButton.backgroundColor = [UIColor greenColor];
        [_appstoreButton setImage:[UIImage imageNamed:@"ButtonLove"] forState:UIControlStateNormal];
        [_appstoreButton setTitle:@"到App Store评价我们" forState:UIControlStateNormal];
        [self addSubview:_appstoreButton];
        _weiboButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _weiboButton.backgroundColor = [UIColor orangeColor];
        [_weiboButton setTitle:@"新浪微博推荐给好友" forState:UIControlStateNormal];
        [_weiboButton setImage:[UIImage imageNamed:@"ButtonPlayVideo"] forState:UIControlStateNormal];
        [self addSubview:_weiboButton];
        _cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _cancelButton.backgroundColor = [UIColor blueColor];
        [_cancelButton setTitle:@"取消" forState:UIControlStateNormal];
        [self addSubview:_cancelButton];
        
        
        _moreViewCollection = [[UICollectionView alloc] initWithFrame:CGRectMake(10, 170, 355, 200) collectionViewLayout:_flow];
        _moreViewCollection.backgroundColor = [UIColor whiteColor];
        _moreViewCollection.delegate = self;
        _moreViewCollection.dataSource = self;
        
        [self addSubview:_moreViewCollection];
        
        [_moreViewCollection registerClass:[MoreViewCollectionViewCell class] forCellWithReuseIdentifier:@"moreViewCollectionCell"];
    }
    return self;
}


- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    MoreViewCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"moreViewCollectionCell" forIndexPath:indexPath];

    cell.linkImageView.image = [UIImage imageNamed:@"ButtonPlayVideo"];
    cell.linkLabel.text = @"微信朋友圈";
    return cell;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 6;
}

- (void)layoutSubviews
{
    _moreLabel.frame = CGRectMake(5, 5, 300, 20);
    _appstoreButton.frame = CGRectMake(10, 30, 355, 60);
    _weiboButton.frame = CGRectMake(10, 100, 355, 60);
    _cancelButton.frame = CGRectMake(10, 450, 355, 50);
}

@end
